package com.web.servlet.manager;

import java.util.ArrayList;

import com.sun.tools.javac.util.List;
import com.web.servlet.bean.GameInfo;
import com.web.servlet.bean.GameServerInfo;
import com.web.servlet.dao.GameServerInfoDao;
import com.web.servlet.dao.impl.GameServerInfoDaoImpl;

public class GameServerMananger extends BaseManager {
	public static ArrayList<GameServerInfo> gameServerInfoList = new ArrayList<GameServerInfo>();//游戏服务器列表
	public static ArrayList<GameInfo> gameInfoList = new ArrayList<GameInfo>();//游戏列表
	private static GameServerMananger gameServerMananger;
	@Override
	public void init() {
		GameServerInfoDao dao = new GameServerInfoDaoImpl();
		gameServerInfoList.addAll(dao.getGameServerInfoAll());
		gameInfoList.addAll(dao.getGameInfoAll());
	}
	public static synchronized GameServerMananger getInstance() {
		if (gameServerMananger == null) {
			gameServerMananger = new GameServerMananger();
		}
		return gameServerMananger;
	}
	public static ArrayList<GameServerInfo> getGameServerInfoList(){
		return gameServerInfoList;
	}
	public static ArrayList<GameInfo> getGameInfoList(){
		return gameInfoList;
	}
	public static GameInfo getGameInfoByID(int id){
		GameInfo info = null;
		for (GameInfo gameInfo : gameInfoList) {
			if(id == gameInfo.getGame_id()){
				info = gameInfo;
				break;
			}
		}
		return info;
	}
	public static GameServerInfo getGameServerInfoByID(int id){
		GameServerInfo info = null;
		for (GameServerInfo gameInfo : gameServerInfoList) {
			if(id == gameInfo.getGame_id()){
				info = gameInfo;
				break;
			}
		}
		return info;
	}
}
